<template>
  <view>
    <u-navbar :is-back="false" title="　" :border-bottom="false">

    </u-navbar>
    <view @click="handleClickMenu('shopDetail')" class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30">
      <view class="u-m-r-10">
        <u-avatar :src="storeData.storeLogo" size="140"></u-avatar>
      </view>
      <view class="u-flex-1">
        <view class="u-font-18 u-p-b-20">{{storeData.storeName}}</view>
        <view class="u-font-12 u-tips-color">{{storeData.storeAddressPath +'-'+storeData.storeAddressDetail}}</view>
      </view>

      <view class="u-m-l-10 u-p-10">
        <u-icon name="arrow-right" color="#969799" size="28"></u-icon>
      </view>
    </view>

   <!-- <view class="u-m-t-20">
      <u-cell-group>
        <u-cell-item title="配送模板"></u-cell-item>
      </u-cell-group>
    </view> -->

    <view class="u-m-t-20">
      <u-cell-group>
        <u-cell-item @click="handleClickMenu('shopAddress')" title="自提管理"></u-cell-item>
        <u-cell-item @click="handleClickMenu('logistics')" title="物流公司"></u-cell-item>
        <u-cell-item @click="handleClickMenu('returnGoods')" title="退货地址"></u-cell-item>
        <u-cell-item @click="handleClickMenu('stockWarning')" title="库存预警"></u-cell-item>
		<u-cell-item @click="loginOut" title="退出登录"></u-cell-item>
      </u-cell-group>
    </view>
  </view>
</template>

<script>
import { getShopInfo } from "@/api/shops";
import { loginOutAsync } from "@/api/login.js"
export default {
  data() {
    return {
      show: true,
      storeData: {}, //店铺详情
    };
  },
  onLoad() {},
  onShow() {
    this.init();
  },
  methods: {
	  loginOut(){
		  uni.showModal({
		  	content: '您确定要退出登录吗？',
		  	success: function (res) {
		  		if (res.confirm) {
		  			loginOutAsync().then(res=>{
						if(res.data.code === 200){
							uni.showToast({
								title:"操作成功",
								icon:"none",
								duration:500
							})
							setTimeout(()=>{
								uni.clearStorageSync()
								uni.reLaunch({
									url:"/pages/passport/login"
								})
							})
						}
					})
		  		}
		  	}
		  })
	  },
    // 初始化店铺详情
    async init() {
      let res = await getShopInfo();
      if (res.data.success) {
        this.storeData = res.data.result;
      }
    },
    handleClickMenu(val) {
      switch (val) {
        case "setup":
          uni.switchTab({
            url: `/pages/tabbar/user/my`,
          });
          break;
        case "logistics":
          uni.navigateTo({
            url: "/pages/other/setup/logistics",
          });
          break;
        case "stockWarning":
          uni.navigateTo({
            url: `/pages/other/setup/stockWarning?num=${this.storeData.stockWarning}`,
          });
          break;
        case "returnGoods":
          uni.navigateTo({
            url: `/pages/other/setup/returnGoodsAddress`,
          });
          break;
        case "shopAddress":
          uni.navigateTo({
            url: `/pages/other/setup/shopAddressList`,
          });
          break;
        case "shopDetail":
          uni.navigateTo({
            url: `/pages/other/setup/shopDetail?data=${encodeURIComponent(
              JSON.stringify(this.storeData)
            )}`,
          });
          break;
      }
    },
  },
};
</script>

<style lang="scss">
page {
  background-color: #ededed;
}

.camera {
  width: 54px;
  height: 44px;

  &:active {
    background-color: #ededed;
  }
}
.user-box {
  background-color: #fff;
}
</style>
